{include file='pub/header'/}
<title>分类编辑</title>
<link href="__STATIC__/lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="page-container">
	<form class="form form-horizontal" id="form-category-edit">
		<input type="hidden" name="id" value="{$cate.id}"/>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>分类名称：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$cate.name}" placeholder="" id="name" name="name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">排序值：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$cate.ord}" placeholder="" id="orderid" name="ord">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">分类图标：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<div class="uploader-thum-container">
					<div id="fileList" class="uploader-list">
						{if $cate.image!=""}
						<img src="{$cate.image}" style="width: 100px; height: 100px;"/>
						{/if}
					</div>
					<div id="filePicker">选择图片</div>
				</div>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">分类文字图标：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<div class="uploader-thum-container">
					<div id="fileList1" class="uploader-list">
						{if $cate.word_image!=""}
						<img src="{$cate.word_image}" style="width: 100px; height: 100px;"/>
						{/if}
					</div>
					<div id="filePicker1">选择图片</div>
				</div>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">导航是否显示：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<div class="uploader-thum-container">
					<label for=""><input type="radio" value="1" class="check-box" {if $cate.is_index eq 1}checked{/if} placeholder="" name="is_index">是</label>
					<label for=""><input type="radio" value="0" class="check-box" {if $cate.is_index eq 0}checked{/if} placeholder="" name="is_index">否</label>
				</div>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">首页推荐：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<label for=""><input type="radio" value="1" class="check-box" placeholder="" {if $cate.is_recommond eq 1}checked{/if} name="is_recommond">是</label>
				<label for=""><input type="radio" value="0" class="check-box" placeholder="" {if $cate.is_recommond eq 1}checked{/if} name="is_recommond">否</label>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">推荐商品数量：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="number" class="input-text" value="8" placeholder="" name="show_num">
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button class="btn btn-secondary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
				<button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
			</div>
		</div>
	</form>
</div>


{include file="pub/footer"/}
<script type="text/javascript" src="__STATIC__/lib/webuploader/0.1.5/webuploader.min.js"></script>
<script type="text/javascript">
    $(function(){
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        uploadImage($("#fileList"), null, $("#form-category-edit"), "image");
        uploadImage($("#fileList1"), null, $("#form-category-edit"), "word_image", "#filePicker1", 1);

        $("#form-category-edit").validate({
            rules:{
                name:{
                    required:true
                }
            },
            messages:{
                name:{
                    required:'分类名称不能为空'
                }
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                $(form).ajaxSubmit({
                    type: 'post',
                    url: '{:url("Category/categoryEdit")}',
                    success:function(res){
                        if(1 == res.code){
                            var index = parent.layer.getFrameIndex(window.name);
                            layer.msg(res.msg, {icon:6, time:1000});
                            setTimeout(function(){
                                parent.location.reload();
                                parent.layer.close(index);
                            }, 1000);
                        }else{
                            layer.msg(res.msg, {icon: 5,time:1000});
                        }
                    }});

            }
        });


    });
</script>
</body>
</html>